package com.viviet.mobileservices.common;

import com.opensymphony.xwork2.ActionSupport;
import com.viviet.mobileservices.domain.info.MessageInfo;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;
import org.apache.struts2.util.ServletContextAware;

public class BaseAction extends ActionSupport implements ServletRequestAware,
		ServletResponseAware, SessionAware, ServletContextAware {
	private static final long serialVersionUID = 12241241241245L;
	private HttpServletRequest servletRequest;
	private ServletContext servletContext;
	private HttpServletResponse servletResponse;
	private Map session;

	public HttpServletResponse getServletResponse() {
		return this.servletResponse;
	}

	public void setServletResponse(HttpServletResponse servletResponse) {
		this.servletResponse = servletResponse;
	}

	public ServletContext getServletContext() {
		return this.servletContext;
	}

	public HttpServletRequest getServletRequest() {
		return this.servletRequest;
	}

	public void setSession(Map session) {
		this.session = session;
	}

	public Map getSession() {
		return this.session;
	}

	public void setServletContext(ServletContext arg0) {
		this.servletContext = arg0;
	}

	public void setServletRequest(HttpServletRequest servletRequest) {
		this.servletRequest = servletRequest;
	}

	protected MessageInfo createMessage(int msgType, String msgCode,
			String msgContent) {
		MessageInfo msg = new MessageInfo();
		msg.setMsgType(msgType);
		msg.setMsgCode(msgCode);
		msg.setMsgContent(getText(msgContent));

		return msg;
	}
}